const { ref } = Vue
import { useFetch } from '../../../Scripts/hooks/useFetch.js'

export function getChildContainerData() {
  const childContainerList = ref([]);
  const childContainerTableRef = ref(null);// 页面 【子批次号】ref引用
  const getContainerType7List = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        type: `${configObj.method}`,
        mfgordername: configObj.mfgordername,
        togetherflag: configObj.togetherflag,
        productid: configObj.productid,
        workflowstepid: configObj.workflowstepid,
        factoryid: configObj.factoryid,
        workerid: configObj.workerid,
        queryType: configObj.queryType
      }
    });
    for (const i of data.value) { i.status = false; }
    childContainerList.value = data.value;
    return data.value;
  }

  const getContainerType3List = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        type: `${configObj.method}`,
        parentcontainerid: `${configObj.parentcontainerid}`
      }
    });
    for (const i of data.value) { i.status = false; } // 是否报废 默认都为'否'
    childContainerList.value = data.value;
  }

  return {
    childContainerList,
    childContainerTableRef,
    getContainerType7List,
    getContainerType3List
  }
}